<?php
 header("Content-Type: text/html; charset=utf-8"); error_reporting( E_ERROR | E_WARNING ); $paths = array('upload/','upload1/'); $action = htmlspecialchars( $_POST[ "action" ] ); if ( $action == "get" ) { $files = array(); foreach ( $paths as $path){ $tmp = getfiles( $path ); if($tmp){ $files = array_merge($files,$tmp); } } if ( !count($files) ) return; rsort($files,SORT_STRING); $str = ""; foreach ( $files as $file ) { $str .= $file . "ue_separate_ue"; } echo $str; } function getfiles( $path , &$files = array() ) { if ( !is_dir( $path ) ) return null; $handle = opendir( $path ); while ( false !== ( $file = readdir( $handle ) ) ) { if ( $file != '.' && $file != '..' ) { $path2 = $path . '/' . $file; if ( is_dir( $path2 ) ) { getfiles( $path2 , $files ); } else { if ( preg_match( "/\.(gif|jpeg|jpg|png|bmp)$/i" , $file ) ) { $files[] = $path2; } } } } return $files; } 